<?php
$conn = mysql_connect("localhost","root","");
$userLogin = $_POST["login"];
$usuarioSenha = $_POST["senha"];
if (!$conn)
{
   die('Could not connect: '. mysql_error());
}
mysql_selectdb("scae");
$r = mysql_query("select * from usuario where nomeLogIn = '".$userLogin."'");
if($_SERVER['REQUEST_METHOD']=='POST'){
	$logado = false;
	while ($row = mysql_fetch_array($r)){
		if($row["senha"]==$usuarioSenha){
			$logado = true;
			session_start();
			$_SESSION['usuario'] = $usuario;
			break;
		}
	}

    if($logado){
	   header("Location: inicial.html");
    }else{
	   header("Location: index.php");
     }
}
$conn = mysql_close();
?>